package com.jeffse.light.stream.core.data.descriptor.operatorDescriptor;

import com.jeffse.light.stream.core.constans.OutTagConstans;
import com.jeffse.light.stream.core.data.context.Context;
import com.jeffse.light.stream.core.pojo.window.SlideWindowInfo;
import com.jeffse.light.stream.core.pojo.window.WindowInfo;
import com.jeffse.light.stream.core.function.base.Function;
import com.jeffse.light.stream.core.function.base.WaterMarkFunction;
import com.jeffse.light.stream.core.pojo.OutTag;
import com.jeffse.light.stream.core.selector.KeyedSelector;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * 数据操作函数描述符
 */
@Data
@NoArgsConstructor
public class OperatorDescriptor implements Serializable {
    protected OutTag outTag;
    protected String name;
    protected Function func;
    protected KeyedSelector keyedSelector;
    protected WaterMarkFunction waterMarkFunction;
    protected Context ctx = null;
    protected WindowInfo windowInfo = null;
    protected SlideWindowInfo slidWindowInfo = null;
    protected OperatorDescriptor netOperatorDescriptor = null;

    public OperatorDescriptor(Context ctx, String name){
        this.name = name;
        this.ctx = ctx;
        setOutTag(null);
    }

    public OperatorDescriptor(Context ctx, String name, Function func){
        this.name = name;
        this.func = func;
        this.ctx = ctx;
        setOutTag(null);
    }

    public OperatorDescriptor(Context ctx, String name, Function func, KeyedSelector keyedSelector){
        this.name = name;
        this.func = func;
        this.ctx = ctx;
        this.keyedSelector = keyedSelector;
        setOutTag(null);
    }

    public OperatorDescriptor(Context ctx, String name, Function func, KeyedSelector keyedSelector, WaterMarkFunction waterMarkFunction){
        this.name = name;
        this.func = func;
        this.ctx = ctx;
        this.keyedSelector = keyedSelector;
        this.waterMarkFunction = waterMarkFunction;
        setOutTag(null);
    }

    public OperatorDescriptor(Context ctx, String name, OutTag outTag){
        this.name = name;
        this.ctx = ctx;
        setOutTag(outTag);
    }

    public OperatorDescriptor(Context ctx, String name, Function func, OutTag outTag){
        this.name = name;
        this.func = func;
        this.ctx = ctx;
        setOutTag(outTag);
    }

    public OperatorDescriptor(Context ctx, String name, Function func, KeyedSelector keyedSelector, OutTag outTag){
        this.name = name;
        this.func = func;
        this.ctx = ctx;
        this.keyedSelector = keyedSelector;
        setOutTag(outTag);
    }

    public OperatorDescriptor(Context ctx, String name, Function func, KeyedSelector keyedSelector, WaterMarkFunction waterMarkFunction, OutTag outTag){
        this.name = name;
        this.func = func;
        this.ctx = ctx;
        this.keyedSelector = keyedSelector;
        this.waterMarkFunction = waterMarkFunction;
        setOutTag(outTag);
    }

    public void setOutTag(OutTag outTag){
        this.outTag = outTag;
        if(outTag == null){
            this.outTag = new OutTag(OutTagConstans.MAIN);
        }
    }

}
